'use strict';

var React = require('react');
var Router = require('react-router'); 
var RouteHandler = Router.RouteHandler;

var RADIO_DEFAULT = 0;
var RADIO_HOVER = 1;
var RADIO_CHECK = 2;
var RADIO_DISABLE = 3;

var RadioBoxComponent = React.createClass({
  getInitialState : function(){
    return { check : RADIO_DEFAULT  }; 
  },
  handleToggle : function(){
      this.props.selectItem(this);
  },
  handleHover : function(){
    if(this.state.check == RADIO_DEFAULT)
      this.setState({ check : RADIO_HOVER });
  },
  handleOut : function(){
    if(this.state.check == RADIO_HOVER)
    this.setState({ check : RADIO_DEFAULT });
  },
  render: function() {
  
   var icons;

    
    switch(this.state.check){
      case RADIO_DEFAULT:
        icons = <span className="do-radio-default"></span>;
        break;
      case RADIO_HOVER:
        icons = <span className="do-radio-hover"></span>;
        break;
    };

    var selected = this.props.isSelected;
    if(selected)
      icons = <span className="do-radio-check"></span>;

  
    
    return (
      /* jshint ignore:start */
          <div className="do-radio" key={ this.props.key } onMouseEnter={ this.handleHover } onMouseLeave={this.handleOut} onClick={ this.handleToggle }>
            { icons }{ this.props.text }
          </div>
      /* jshint ignore:end */
    );
  }
});

module.exports = RadioBoxComponent;
